#include "queuestack.h"

void Queue::push(int data) 
{
   ListNode* temp = new ListNode(data);  
   if (head == NULL) 
   {					   
       head = temp;
       tail = temp;
   }
   else
       tail->next = temp;  
	tail = temp;
	Size++;
}
int Queue::pop()
{
	if(head==NULL) return -1;
	int a = head->data; 
    ListNode* ptr=head->next; 
    delete head;  
    head =ptr; 
	Size--;
	return a; 
}
Queue::~Queue()
{
	while (Size>0) pop(); 	
}
void Stack::push(int a) 
{
    ListNode* ptr=new ListNode(a);
    ptr->next=head;
    head=ptr;
    Size++;
}
int Stack::pop() 
{
    if(Size==0) return -1;//��ջ���� 
    ListNode* temp=head;
    int a = head->data;
    head=head->next;
    delete temp;
    Size--;
    return a;
}
Stack::~Stack()
{
	while (Size>0) pop();  	
}
